#ifndef cathlibcpp_new_H
#define cathlibcpp_new_H

// File:       new.h
// Author:     (c) Miles Sabin, 1996
// Purpose:    dynamic storage allocation


#ifndef included_stddef_H
#define included_stddef_H
#include <stddef.h>                   // for size_t
#endif

#ifndef cathlibcpp_config_H
#include "config.h"
#endif

#ifndef cathlibcpp_exception_H
#include "exception.h"                  // for exception
#endif


// new and delete

void* operator new(size_t size);

struct nothrow { nothrow(){} };
void* operator new(size_t size, nothrow const&);

void  operator delete(void* ptr);


// placement new

inline void* operator new(size_t, void* p)
{
  return p;
}


// storage allocation errors

class bad_alloc : public exception
{
  public:

    bad_alloc();
    ~bad_alloc();

    void* operator new(size_t);
    void operator delete(void*, size_t);

    char const* what() const;

    RTTI_SCAFFOLDING_DECL
};


// new handler

typedef void (*new_handler)();

new_handler set_new_handler(new_handler new_p);

#endif
